﻿/*----------------------------------------------------------------
// Copyright (C) 2012 zhangqiang
// 版权所有。 
//
// 文件名：DataAccessInstaller.cs
// 文件功能描述：数据层的安装类
//
// 
// 创建标识：2012-10-21 zhangqiang
//
// 修改标识：
// 修改描述：
//
//
//----------------------------------------------------------------*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Castle.MicroKernel.Registration;
using Castle.Windsor;
using Castle.MicroKernel.SubSystems.Configuration;
using Manager.Infrastructure;
using Manager;

namespace Client.Windsor
{
    /// <summary>
    /// 数据层的安装类
    /// </summary>
    public class DataAccessInstaller : IWindsorInstaller
    {
        /// <summary>
        /// 安装方法
        /// </summary>
        /// <param name="container">容器</param>
        /// <param name="store">配置文件</param>
        public void Install(IWindsorContainer container, IConfigurationStore store)
        {
            //SqlMapClient smc = new SqlMapClient();
            //smc.SqlMapConfig = @"Config\ibatisConfig\SqlMapOracle.config";
            //container.Register(Component.For<SqlMapClient>().Instance(smc).LifestyleSingleton());
            //注册事务类
            container.Register(
                           Component.For<IUnitOfWork>().ImplementedBy<UnitOfWork>().LifestylePerWebRequest()
                           );
            //注册数据库连接类
            container.Register(
                            Component.For<IDbContextFactory>().ImplementedBy<DbContextFactory>().LifestylePerWebRequest()
                            );

            //container.Register(
            //    (Classes.FromAssemblyNamed("DataAccess").Where(n => n.Name.StartsWith("DataAccess"))
            //    //.WithServiceDefaultInterfaces()
            //    .WithServiceAllInterfaces()
            //    .LifestylePerWebRequest())
            //    );
        }
    }
}